package com.shigen.springcloud.controller;

import com.shigen.springcloud.service.PaymentService;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "payment/hystrix")
public class PaymentController {

  @Resource
  private PaymentService paymentService;

  @Value("${server.port}")
  private String port;

  @GetMapping(value = "ok/{id}")
  public String payment_OK(@PathVariable("id") Integer id) {
    return paymentService.payment_OK(id);
  }

  @GetMapping(value = "timeout/{id}")
  public String payment_TimeOut(@PathVariable("id") Integer id) {
    return paymentService.payment_TimeOut(id);
  }

  @GetMapping(value = "circuit/{id}")
  public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
    return paymentService.paymentCircuitBreaker(id);
  }
}
